package org.abbett.eskine.controller;

import org.abbett.eskine.service.HomeLoginLoginOutcome;
import org.abbett.eskine.service.HomeSignUpSignUpOutcome;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

/**
 * Glue code to bind Log In or Sign Up Service with the view framework (Seam)
 * 
  * This page provides a login form and a sign-up form.
  *
 * Automatically generated by clickframes
 * 
 * @author Vineet Manohar
 */
@Name("homeController")
@Scope(ScopeType.CONVERSATION)
public class HomeController extends GeneratedHomeController {
    @SuppressWarnings("unused")
    private final Log logger = LogFactory.getLog(getClass());


    private HomeLoginLoginOutcome forceLogin(String username, String password) {
    	this.setLoginEmail(username);
    	this.setLoginPassword(password);
    	return this.loginLogin();
    }
 
    /**
     * Sign Up
     *
      * Automatically generated by clickframes
     */
    @Override
    public HomeSignUpSignUpOutcome signUpSignUp() {
        logger.warn("Method not implemented yet.  Please implement HomeService.signUpSignUp()");
    
        signUpSignUpResponse = homeService.signUpSignUp(signUpForm());
        if (signUpSignUpResponse.getOutcome() == HomeSignUpSignUpOutcome.accountCreated) {
        	forceLogin(getSignUpEmail(), getSignUpPassword());
        }

        return signUpSignUpResponse.getOutcome();
    }

    private static final long serialVersionUID = 1L;
}// clickframes::version=1047495921::clickframes